package org.dei.perla.aggregates;

import org.dei.perla.parser.expressions.ConstantFloat;
import org.dei.perla.parser.expressions.ConstantID;
import org.dei.perla.parser.expressions.ConstantInteger;
import org.dei.perla.parser.expressions.ConstantTimestamp;
import org.dei.perla.parser.expressions.ConstantVectorFloat;
import org.dei.perla.sys.query.llqruntime.datastructures.Buffer;
import org.dei.perla.sys.query.llqruntime.datastructures.QueryRecordStructure;

public class MainVariance {

	public static void main(String s[]){
		
		try{
/*
 Defining the field structure
 */
			QueryRecordStructure parQueryRecordStructure = new QueryRecordStructure();
			parQueryRecordStructure.addFieldStructure("ID", ConstantID.class);
			parQueryRecordStructure.addFieldStructure("TS",ConstantTimestamp.class); 
			parQueryRecordStructure.addFieldStructure("TEMP", ConstantInteger.class);
			
			Buffer buffer = StreamVariance.randomBuffer(parQueryRecordStructure);
			ConstantVectorFloat sample = StreamVariance.sampleArray(buffer, "TEMP");
			ConstantFloat variance = (ConstantFloat) StatisticSample.variance(sample);
			System.out.println(variance);
		}catch (Exception e){
			e.printStackTrace();
		}
	}

}
